package com.alibaba.cloud.boot.order.facade.fallback;

import com.alibaba.cloud.boot.order.facade.DefaultStockFacade;
import com.alibaba.cloud.boot.order.facade.StockFacade;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class StockFallbackFactory implements FallbackFactory<DefaultStockFacade> {


    @Override

    public DefaultStockFacade create(Throwable cause) {
        System.out.println(cause);
       return new DefaultStockFacade() {
           @Override
           public String reduceStockCount(int stockId, int stockCount) {
               System.out.println("扣减库存降级");
               return "扣减库存降级";
           }

           @Override
           public String mustFail() {
               System.out.println("mustFail降级");
                return "mustFail降级";
           }
       };
    }
}
